package com.sky.controller;

import com.sky.entity.Note;
import com.sky.service.NoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/visa/note")
public class NoteController {
    @Autowired
    private NoteService noteService;

    @GetMapping
    public List<Note> list() {
        return noteService.list();
    }

    @PostMapping
    public Note add(@RequestBody Note note) {
        noteService.add(note);
        return noteService.getById(note.getId());
    }

    @PutMapping
    public void update(@RequestBody Note note) {
        noteService.update(note);
    }

    @DeleteMapping("/{id}")
    public Long delete(@PathVariable Long id) {
        noteService.delete(id);
        return id;
    }
}
